import tornado.ioloop
import tornado.web


class IndexHandler(tornado.web.RequestHandler):
    def get_current_user(self) -> tornado.ioloop.Any:
        return 'zzd'

    # login
    @tornado.web.authenticated
    def get(self):
        self.write('Hello, world')
        # self.set_cookie(expires_days=2)


class LoginHandler(tornado.web.RequestHandler):
    def get(self):
        self.write('Hello, world')


def make_app():
    return tornado.web.Application(
        [
            (r'/', IndexHandler),
            (r'login/', LoginHandler),
        ],
        debug=True,
        login_url='/login'
    )


if __name__ == '__main__':
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()
